<!--
 * @Author: xjt
 * @Date: 2021-06-24 23:05:13
 * @LastEditTime: 2021-07-03 20:47:15
 * @Description: 酒店基本信息
 * @LastEditors: cqg
-->
<template>
  <basic-container v-loading="loading" element-loading-text="数据加载中...">
    <div class="v-medicalMonitor-basi">
      <dataList
        placeholder="请输入姓名"
        :menuList="[]"
        searchName="name"
        :pageInfo="pager"
        :listData="tableData"
        :filterList="filterList"
        :selectData="selectDataArr"
        :dataInfo="dataInfo"
        :operaInfo="operaInfo"
        @btn-click="newlyFunc"
        :openIndex="true"
        operaColumnWidth="100"
      ></dataList>
      <!-- 新增 -->
      <hotelDialog
        :popUpdata="popUpdata"
        ref="hotelDialog"
        title="每日监控检测"
        width="80%"
      ></hotelDialog>

      <!-- 健康填报 -->
      <newlyStatus
        width="80%"
        :popUpdata="newlydata"
        ref="newlyStatus"
        @submit="submitHealth"
        title="健康填报"
        @dataRadio="dataRadio"
      >
        <template v-slot:custom="scope">
          <el-checkbox-group v-model="scope.scope.value" :disabled="zzdisabled">
            <el-checkbox
              @change="optionChang(val.value, scope.scope)"
              v-for="val in filterradioList(scope.scope)"
              :key="val.value"
              :label="val.value"
              >{{ val.label }}</el-checkbox
            >
          </el-checkbox-group>

          <el-checkbox-group
            v-if="scope.scope.secondState"
            v-model="scope.scope.extraObj.value"
            :disabled="zzdisabled"
          >
            <el-checkbox
              v-for="val in filterradioList(scope.scope.extraObj)"
              @change="optionChangTwo(val.value, scope.scope.extraObj)"
              :key="val.value"
              :label="val.value"
              >{{ val.label }}</el-checkbox
            >
          </el-checkbox-group>

          <el-input
            v-model="scope.scope.extraObj.extraObj.value"
            placeholder="请输入其它原因"
            v-if="scope.scope.extraObj && scope.scope.extraObj.otherState"
          />
        </template>
      </newlyStatus>
    </div>

    <!-- 日常监测 -->
    <hotelDialog
      :popUpdata="popUpdata"
      ref="particulars"
      title="日常监测"
      width="80%"
      @submit="additional"
      @close="close"
      @handleClick="handleClick"
    >
      <template v-slot:custom>
        <div style="text-align:right">
          <el-button @click="increased" type="primary">新增</el-button>
        </div>
        <ul class="tabs-ul">
          <Li
            :class="{ active: curIndex === item.value }"
            v-for="item in healthHeader"
            :key="item.value"
            @click="changeTabs(item.value)"
            >{{ item.name }}</Li
          >
        </ul>

        <div class="myChart" ref="myChartfath">
          <div id="myChart" ref="myChart"></div>
        </div>

        <div class="history-div">
          <p class="title">历史健康</p>

          <template v-if="historyData.length">
            <div
              class="history-detail"
              v-for="(item, index) in historyData"
              :key="index"
            >
              <span class="timer">{{ item.gcsj }}</span>
              <span>
                体温
                <span class="heat">{{ item.tw }}°</span>
              </span>
              <span>
                症状
                <span>{{ collaborative(item) }}</span>
              </span>
              <span>
                核酸采样
                <span>{{ screen(item.hsjg, 'is_valid') }}</span>
              </span>
              <span v-if="item.hsjg == '1'">
                采样方式
                <span>{{ screen(item.cyfs, 'sample_mode') }}</span>
              </span>
              <span>
                采样时间
                <span>{{ item.creatime }}</span>
              </span>
              <span>
                血糖
                <span>{{ item.xt }}vmmool/L</span>
              </span>
              <span>
                血压
                <span>{{ item.xygy }}/{{ item.xydy }}毫米汞柱</span>
              </span>
              <span>
                中药治疗
                <span>{{ screen(item.zyzl, 'is_valid') }}</span>
              </span>
              <span>
                医学建议
                <span>{{ item.yxjy }}</span>
              </span>
              <el-button
                class="update"
                type="primary"
                size="small"
                @click="updateStatus(item)"
                >修改</el-button
              >
            </div>
          </template>

          <template v-else>暂无数据</template>
        </div>
      </template>
    </hotelDialog>
  </basic-container>
</template>
<script>
import { deleteDecoration } from '@/views/wy-operate/api/decorate.js';
import hotelDialog from './dialog'; // 日常监测
import newlyStatus from './addIofo';
import {
  dailyhealth,
  addisolate,
  getpagequery,
  isolateisolateId,
  putisolate,
  dailyhealthpage,
  updateDailyhealth,
} from '@/views/yq-personnel/api/health.js';
import {
  conversion,
  extractName,
  reversalData,
  nowDate,
} from '@/utils/extract';
import { getDict } from '@/utils';
import dateFormate from '@/assets/js/date';
import echarts from 'echarts';
import { setTimeout } from 'timers';

export default {
  components: {
    hotelDialog,
    newlyStatus,
  },
  provide() {
    return {
      //初始化数据
      initList: this.queryData,
    };
  },
  beforeMount() {
    this.queryData();
  },
  mounted() {},
  data() {
    return {
      minNum: '35',
      maxNum: '41',
      echarsData: [],
      echartsXdata: [],
      twData: [],
      xtData: [],
      xygyData: [],
      xydyData: [],
      substitute: [],
      // 表格列表数据
      tableData: [],
      curIndex: 0,
      healthHeader: [
        { name: '温度曲线', value: 0 },
        { name: '血糖曲线', value: 1 },
        { name: '血压曲线', value: 2 },
      ],
      // 请求参数
      params: {
        current: 1,
        size: 10,
        keyword: '',
      },
      historyData: [],
      // 选中的数据
      selectDataArr: [],
      // 分页
      pager: {
        total: 0, // 总页数
        current: 1, // 当前页数
        size: 20, // 每页显示多少条
      },
      updateData: {},
      // 页面loading
      loading: false,
      zzdisabled: false, // 控制症状的可选
      popUpdata: [
        {
          label: '姓名',
          value: '',
          key: 'name',
          type: 'input',
          readonly: true,
        },
        {
          label: '性别',
          value: '',
          key: 'gender',
          type: 'dict',
          dictName: 'gender',
          disabled: true,
        },
        { label: '年龄', value: '', key: 'c', type: 'input', readonly: true },
        {
          label: '身份证号或其它证件号',
          value: '',
          key: 'cardId',
          type: 'input',
          readonly: true,
        },
        { label: '房间号', value: '', key: 'e', type: 'input', readonly: true },
        {
          label: '隔离类型',
          value: '',
          key: 'isolateType',
          type: 'radio',
          spanWidth: 24,
          dictName: 'person_classify',
          disabled: true,
        },
        {
          label: '转密原因',
          value: '',
          key: 'zmyx',
          type: 'input',
        },
        {
          label: '判定时间',
          value: null,
          key: 'creatime',
          type: 'time',
          genre: 'datetime',
          readonly: true,
        },
        {
          label: '开始隔离时间',
          value: null,
          key: 'moveStartTime',
          type: 'time',
          genre: 'datetime',
          readonly: true,
        },
        {
          label: '计划结束隔离',
          value: null,
          key: 'moveEndTime',
          type: 'time',
          genre: 'datetime',
          readonly: true,
        },
        { label: '隔离调整情况', value: '', key: 'gltzqk', type: 'input' },

        {
          label: '疫苗注射第一针',
          value: null,
          key: 'ymzsdyz',
          type: 'time',
          genre: 'date',
        },
        {
          label: '第二针',
          value: null,
          key: 'ymzsdez',
          type: 'time',
          genre: 'date',
        },
        {
          label: '疫苗种类',
          value: '',
          key: 'ymzl',
          type: 'dict',
          dictName: 'vaccine_type',
          showValue: '17',
          extraObj: {
            value: '',
            key: 'qtym',
          },
        },
        { label: '流行病学史', value: '', key: 'lxbxs', type: 'input' },
        { label: '基础性疾病', value: '', key: 'jzxjb', type: 'input' },
        {
          label: '疟疾筛查',
          value: null,
          key: 'ljsc',
          type: 'radio',
          spanWidth: 8,
          dictName: 'ying_yang',
        },
        {
          label: '登革热筛查',
          value: null,
          key: 'dgrsc',
          spanWidth: 8,
          type: 'radio',
          dictName: 'ying_yang',
        },
        {
          label: '服药史',
          value: '',
          key: 'ywfys',
          type: 'radio',
          dictName: 'is_valid',
          showValue: '1',
          spanWidth: 24,
          extraObj: {
            type: 'input',
            value: '',
            key: 'fyssm',
          },
        },
        {
          label: '急症病史',
          value: '',
          key: 'ywjzbs',
          type: 'radio',
          dictName: 'is_valid',
          showValue: '1',
          spanWidth: 24,
          extraObj: {
            type: 'input',
            value: '',
            key: 'jzbssm',
          },
        },

        {
          label: '备注',
          value: '',
          spanWidth: 24,
          key: 'bz',
          type: 'textarea',
          class: 'full',
        },
      ],
      newlydata: [
        { label: '体温(°C)', value: '', key: 'tw', type: 'inputNum' },
        {
          label: '血糖(mmol/L)',
          value: '',
          key: 'xt',
          type: 'input',
          type: 'inputNum',
        },
        {
          label: '血压(mmHg)',
          value: '',
          key: 'xygy',
          type: 'inputNum',
          extraObj: {
            type: 'inputNum',
            value: '',
            key: 'xydy',
          },
        },
        // { label: '血压(高压)', value: '', key: 'xygy', type: 'input' },
        {
          label: '观察时间',
          value: null,
          key: 'gcsj',
          type: 'time',
          genre: 'datetime',
        },
        {
          label: '症状',
          value: [],
          key: 'yjzz',
          spanWidth: 24,
          type: 'checkboxgroup',
          custom: true,
          dictName: 'symptoms',
          secondState: false,
          extraObj: {
            value: [],
            key: 'ejzz',
            dictName: 'second_symptoms',
            extraObj: {
              key: 'qtzz',
              value: '',
            },
            otherState: false,
          },
        },
        {
          label: '核酸采样',
          value: '',
          key: 'hsjg',
          type: 'radio',
          dictName: 'is_valid',
        },
        {
          label: '采样方式',
          value: '',
          key: 'cyfs',
          type: 'radio',
          spanWidth: 24,
          show: true,
          dictName: 'sample_mode',
        },
        {
          label: '中药治疗',
          value: '',
          key: 'zyzl',
          type: 'radio',
          dictName: 'is_valid',
        },
        {
          label: '医学建议',
          spanWidth: 24,
          value: '',
          key: 'yxjy',
          type: 'textarea',
          class: 'full',
        },
      ],
      // 选中的数据
      selectData: {},
    };
  },
  computed: {
    // 操作按钮
    operaInfo() {
      return [
        // { label: '新增', name: 'addData', verify: (row) => !row.isolateId },
        // { label: '编辑', name: 'deiot', verify: (row) => row.isolateId },
        {
          label: '医学观察',
          name: 'preview',
        },
      ];
    },
    // 筛选项
    filterList() {
      return [
        {
          label: '电话号码',
          inputType: 'input',
          name: 'telPhone',
        },
        { label: '证件号码', inputType: 'input', name: 'cardId' },
        { label: '房号', inputType: 'input', name: 'roomNum' },
        {
          label: '人员类型',
          inputType: 'dict',
          name: 'personClassify',
          dictName: 'person_classify',
        },
        {
          label: '入住时间',
          inputType: 'daterange',
          name: ['moveStartTime', 'moveEndTime'],
        },
        {
          label: '日常监测次数',
          inputType: 'input',
          name: 'dcnt',
          defaultValue: '',
        },
      ];
    },
    dataInfo() {
      return [
        { label: '隔离点名称', prop: 'hotelName' },
        // { label: "详细地址", prop: "hotelAddr" },
        { label: '房号', prop: 'roomNum', width: '80px', sortable: true },
        { label: '姓名', prop: 'name', width: '100px' },
        // {
        //   label: "证件类型",
        //   prop: "cardType",
        //   formatter: this.dataFormatter,
        //   width: "100px",
        // },
        // { label: "证件号码", prop: "cardId", width: "200px" },
        { label: '电话号码', prop: 'telPhone', width: '160px' },
        {
          label: '入住开始时间',
          prop: 'moveStartTime',
          formatter: this.dataFormatter,
          sortable: true,
        }, // 去掉秒的显示
        {
          label: '入住终止时间',
          prop: 'moveEndTime',
          formatter: this.dataFormatter,
          sortable: true,
        }, // 去掉秒的显示
        {
          label: '人员类型',
          prop: 'personClassify',
          formatter: this.dataFormatter,
          'show-overflow-tooltip': true,
        },
        {
          label: '心里评估等级',
          prop: 'assessmentRiskLevel',
        },
        {
          label: '是否关爱人员',
          prop: 'sign',
          formatter: this.dataFormatter,
        },
        {
          label: '人员状态',
          prop: 'personState',
          formatter: this.dataFormatter,
        },
        {
          label: '日常监测次数',
          prop: 'dcnt',
          width: '70px',
          sortable: true,
        },
      ];
    },
  },
  methods: {
    filterradioList(value) {
      return getDict(value.dictName);
    },
    handleClick() {
      this.getChars();
    },
    collaborative(value) {
      const str1 = this.echo(value.yjzz, 1) || null;
      const str2 = this.echo(value.ejzz, 2) || null;
      const str3 = this.echo(value.qtzz, 3) || null;
      let arr1 = [];
      let arr2 = [];
      let arr3 = [];
      if (str1) {
        arr1 = str1.split(',');
      }
      if (str2) {
        arr2 = str2.split(',');
      }
      if (str3) {
        arr3 = str3.split(',');
      }
      const newArr = arr1.concat(arr2.concat(arr3));
      return newArr.join(',');
    },
    echo(value, type) {
      if (!value) return;
      switch (type) {
        case 1:
          const newValue = value.split(',');
          let str = '';
          newValue.forEach((val) => {
            getDict('symptoms').forEach((item) => {
              if (item.value == val) {
                str += item.label + ',';
              }
            });
          });
          return str.slice(0, str.length - 1);
        case 2:
          const newValues = value.split(',');
          let strs = '';
          newValues.forEach((val) => {
            this.filterradioList(this.newlydata[4].extraObj).forEach((item) => {
              if (item.value == val) {
                strs += item.label + ',';
              }
            });
          });
          return strs.slice(0, strs.length - 1);
        case 3:
          return '' + value;
      }
    },
    close() {
      this.curIndex = 0;
      this.twData = [];
      this.xtData = [];
      this.xygyData = [];
      this.xydyData = [];
      this.substitute = [];
      this.popUpdata = this.$options.data().popUpdata;
    },
    dataRadio(item) {
      if (item.key == 'hsjg') {
        this.newlydata[6].show = item.value == '1' ? false : true;
      }
    },
    optionChang(val, data) {
      if (val == 0) {
        this.minNum = 35;
        this.maxNum = 41;
        if (data.value.indexOf('0') != -1) {
          this.newlydata[4].value = ['0'];
          this.newlydata[4].secondState = false;
          this.newlydata[4].extraObj.otherState = false;
          this.newlydata[4].extraObj.value = [];
          this.newlydata[4].extraObj.extraObj.value = null;
        }
      } else {
        const index = data.value.indexOf('0');
        if (index != -1) {
          this.newlydata[4].value.splice(index, 1);
        }
      }
      if (val == 11) {
        const index = data.value.indexOf('11');
        index != -1 ? (data.secondState = true) : (data.secondState = false),
          (data.extraObj.value = []),
          (this.newlydata[4].extraObj.extraObj.value = null),
          (this.newlydata[4].extraObj.otherState = false);
      }
    },
    optionChangTwo(val, data) {
      if (val == 11) {
        const index = data.value.indexOf('11');
        index != -1 ? (data.otherState = true) : (data.otherState = false),
          (data.extraObj.value = null);
      }
    },
    screen(value, type) {
      if (!value) return;
      let str = '';
      const arr = value.split(',');
      arr.forEach((item, index) => {
        str += extractName(type, item) + ',';
      });
      return str.slice(0, str.length - 1);
    },
    //格式化表格字典值
    dataFormatter(row, column, cellValue) {
      switch (column.property) {
        case 'cardType':
          return extractName('card_type', row.cardType);
        case 'personState':
          return extractName('person_state', row.personState);
        case 'personClassify':
          return extractName('person_classify', row.personClassify);
        case 'moveStartTime':
          return (
            row.moveStartTime &&
            dateFormate.datasng(row.moveStartTime, 'yyyy-MM-dd hh:mm')
          );
        case 'moveEndTime':
          return (
            row.moveEndTime &&
            dateFormate.datasng(row.moveEndTime, 'yyyy-MM-dd hh:mm')
          );
        case 'sign':
          return row.sign == 1 ? '是' : '否';
        default:
          break;
      }
    },
    increased() {
      if (!this.selectData.isolateId) {
        this.$message.warning('请先填写基本信息!');
        return;
      }
      this.newlydata = this.newlydata.map((a) => {
        const result = {
          ...a,
          value:
            typeof a.value === 'number' || typeof a.value === 'string'
              ? ''
              : a.value,
        };
        if (
          a.key === 'gcsj' ||
          a.key === 'yjzz' ||
          a.key === 'ejzz' ||
          a.key === 'hsjg' ||
          a.key === 'cyfs' ||
          a.key === 'zyzl' ||
          a.key === 'yxjy'
        ) {
          result.disabled = false;
        }
        return { ...result };
      });
      this.zzdisabled = false;
      this.newlydata[3].value = nowDate();
      this.$refs.newlyStatus.changeVisible();
      this.getChars();
    },
    updateStatus(data) {
      this.updateData = data;
      this.newlydata = this.newlydata.map((a) => {
        const result = { ...a, value: data[a.key] ? data[a.key] : a.value };
        if (
          a.key === 'gcsj' ||
          a.key === 'yjzz' ||
          a.key === 'ejzz' ||
          a.key === 'hsjg' ||
          a.key === 'cyfs' ||
          a.key === 'zyzl' ||
          a.key === 'yxjy'
        ) {
          result.disabled = true;
        }
        if (a.key === 'yjzz') {
          result.value = data[a.key].split(',');
        }
        return { ...result };
      });
      this.zzdisabled = true;
      this.$refs.newlyStatus.changeVisible({ update: true });
      this.getChars();
    },
    async additional() {
      const value = conversion(this.popUpdata);
      value.personId = this.selectData.personId;
      let data;
      if (this.selectData.isolateId) {
        value.isolateId = this.selectData.isolateId;
        data = await putisolate(value);
      } else {
        data = await addisolate(value);
      }
      if (data.data.code === 0) {
        this.$message.success('操作成功!');
        this.$refs.particulars.changeVisible();
        this.popUpdata = this.$options.data().popUpdata;
        this.queryData();
      }
    },
    async submitHealth(update) {
      const value = conversion(this.newlydata);
      value.personId = this.selectData.personId;
      value.isolateId = this.selectData.isolateId;

      value['yjzz'] = value['yjzz'].join(',');

      value['ejzz'] = value['ejzz'].join(',');
      // if (!value.tw) {
      //   this.$message.warning('请输入体温');
      //   return;
      // }
      // if (!value.xt) {
      //   this.$message.warning('请输入血糖');
      //   return;
      // }
      // if (!value.xygy || !value.xydy) {
      //   this.$message.warning('请输入血压');
      //   return;
      // }
      if (!value.gcsj) {
        this.$message.warning('请选择观察时间');
        return;
      }
      if (value.tw)
        if (parseFloat(value.tw) > 42 || parseFloat(value.tw) < 35) {
          this.$message.warning('请输入正确的体温');
          return;
        }
      if (value.xt)
        if (parseFloat(value.xt) > 35 || parseFloat(value.xt) < 1) {
          this.$message.warning('请输入正确的血糖');
          return;
        }
      if (value.xygy)
        if (parseFloat(value.xygy) > 220 || parseFloat(value.xygy) < 60) {
          this.$message.warning('请输入正确的血压');
          return;
        }
      if (value.xydy)
        if (parseFloat(value.xydy) > 220 || parseFloat(value.xydy) < 60) {
          this.$message.warning('请输入正确的血压');
          return;
        }
      let resultData;
      if (update) {
        value.healthId = this.updateData.healthId;
        resultData = await updateDailyhealth(value);
      } else {
        resultData = await dailyhealth(value);
      }
      if (resultData.data.code === 0) {
        this.$message.success('操作成功!');
        this.$refs.newlyStatus.changeVisible();
        // this.$refs.particulars.changeVisible();
        this.queryData();
        this.newlydata = this.$options.data().newlydata;

        const val = await dailyhealthpage({
          isolateId: this.selectData.isolateId,
          current: 1,
          size: 999,
        });

        this.twData = this.recursion(val.data.data.reverse(), 'tw').reverse();
        this.xtData = this.recursion(val.data.data.reverse(), 'xt').reverse();
        this.xygyData = this.recursion(
          val.data.data.reverse(),
          'xygy'
        ).reverse();
        this.xydyData = this.recursion(
          val.data.data.reverse(),
          'xydy'
        ).reverse();
        this.echartsXdata = this.recursion(
          val.data.data.reverse(),
          'gcsj'
        ).reverse();
        this.echarsData = this.twData;
        let arr = [];
        val.data.data.forEach((item) => {
          item.forEach((val) => {
            arr.push(val);
          });
        });
        this.historyData = arr;
        this.getChars();
      }
    },
    getChars() {
      // 基于准备好的dom，初始化echarts实例
      // let myChart = echarts.init(document.getElementById('myChart'))
      if (this.$refs.myChart) {
        this.$nextTick(() => {
          let myChart = echarts.init(this.$refs.myChart);
          setTimeout(() => {
            myChart.setOption({
              tooltip: {
                formatter(params) {
                  if (params.data > 37.3) {
                    return (
                      '<div>时间：' +
                      params.name +
                      '</div>' +
                      '<div>温度：' +
                      params.data +
                      "<span  style='color:#F61010'>(温度异常)</span>" +
                      '</div>'
                    );
                  }
                  return (
                    '<div>时间：' +
                    params.name +
                    '</div>' +
                    '<div>温度：' +
                    params.data +
                    '</div>'
                  );
                },
              },
              xAxis: {
                type: 'category',
                data: this.echartsXdata,
                // barGap: "10%",
                axisTick: {
                  alignWithLabel: false,
                  show: false,
                },
                axisLabel: {
                  interval: 0, // 坐标轴刻度标签的显示间隔
                  rotate: 20, // 标签倾斜的角度
                },
              },
              yAxis: [
                {
                  type: 'value',
                  axisTick: {
                    // y轴坐标点消失
                    show: false,
                  },
                  min: this.minNum,
                  max: this.maxNum,
                  // axisLabel: { show: false }, //隐藏Y轴的数值
                },
              ],
              grid: {
                top: '20px',
                left: '80px',
                right: '30px',
                bottom: '60px',
              },
              visualMap: {
                show: false,
                outOfRange: {
                  color: ['#6593F7'],
                },
                pieces: [
                  {
                    gt: 37.3,
                    lte: 41,
                    color: '#F61010',
                  },
                ],
              },
              series: [
                {
                  data: this.echarsData,
                  type: 'line',
                  itemStyle: {
                    normal: {
                      color: '#3C76F4', //改变折线点的颜色
                      label: { show: true }, //顶部显示数值
                      lineStyle: {
                        color: '#3C76F4', //改变折线颜色
                      },
                    },
                  },
                  // 箭头
                  markLine: {
                    silent: true,
                    lineStyle: {
                      color: '#333',
                    },
                    data: [
                      {
                        name: '37',
                        yAxis: 37.3,
                      },
                    ],
                  },
                },
                {
                  data: this.substitute,
                  type: 'line',
                  itemStyle: {
                    normal: {
                      color: '#3C76F4', //改变折线点的颜色
                      label: { show: true }, //顶部显示数值
                      lineStyle: {
                        color: '#F86C6C', //改变折线颜色
                      },
                    },
                  },
                },
              ],
            });
          });
        }, 1);
      }

      // // 绘制图表
    },
    changeTabs(value) {
      this.curIndex = value;
      switch (value) {
        case 0:
          this.echarsData = this.twData;
          this.substitute = [];
          this.getChars();
          this.minNum = 35;
          this.maxNum = 41;
          return;
        case 1:
          this.echarsData = this.xtData;
          this.substitute = [];
          this.getChars();
          this.minNum = 1;
          this.maxNum = 35;
          return;
        case 2:
          this.echarsData = this.xygyData;
          this.substitute = this.xydyData;
          this.getChars();
          this.minNum = 60;
          this.maxNum = 220;
          return;
          break;
      }
    },
    async newlyFunc(row = {}) {
      this.selectData = row.row;

      if (row.type === 'deiot' || row.type === 'preview') {
        const { data } = await isolateisolateId(row.row.isolateId);
        reversalData(this.popUpdata, data.data);
      }
      if (row.type !== 'informant') {
        this.popUpdata[0].value = row.row.name;
        this.popUpdata[1].value = row.row.gender;
        this.popUpdata[2].value = row.row.age;
        this.popUpdata[3].value = row.row.cardId;
        this.popUpdata[4].value = row.row.roomNum;
        this.popUpdata[5].value = row.row.personClassify;
        this.popUpdata[6].value = row.row.changeReason;
        this.popUpdata[7].value = row.row.creatime;

        this.popUpdata[8].value = row.row.moveStartTime;
        this.popUpdata[9].value = row.row.moveEndTime;
      }
      if (row.type === 'informant') {
        this.$refs.newlyStatus.changeVisible();
        return;
      } else if (row.type === 'addData' || row.type === 'deiot') {
        this.$refs.hotelDialog.changeVisible();
        return;
      }

      const val = await dailyhealthpage({
        isolateId: this.selectData.isolateId,
        current: 1,
        size: 999,
      });

      this.$refs.particulars.changeVisible();

      this.twData = this.recursion(val.data.data.reverse(), 'tw').reverse();
      this.xtData = this.recursion(val.data.data.reverse(), 'xt').reverse();
      this.xygyData = this.recursion(val.data.data.reverse(), 'xygy').reverse();
      this.xydyData = this.recursion(val.data.data.reverse(), 'xydy').reverse();

      this.echartsXdata = this.recursion(
        val.data.data.reverse(),
        'gcsj'
      ).reverse();
      this.echarsData = this.twData;
      let arr = [];
      val.data.data.forEach((item) => {
        item.forEach((val) => {
          arr.push(val);
        });
      });
      this.historyData = arr;
      this.getChars();
    },
    // 过滤数据
    recursion(data, type) {
      const arr = [];
      data.forEach((item) => {
        item.forEach((data) => {
          arr.push(data[type]);
        });
      });
      return arr;
    },
    // 数据请求
    queryData(params = {}) {
      this.loading = true;
      let requestData = {
        ...this.params,
        ...params,
        personState: '21,22',
        qt: 'yxgc',
      };
      getpagequery(requestData)
        .then((res) => {
          const { current, size, total, records } = res.data.data;
          this.tableData = records;
          this.params = requestData;
          this.pager = { total, current, size };
        })
        .finally(() => {
          this.loading = false;
        });
    },
    // 数据删除
    deleteData() {
      if (this.selectDataArr.length == 0) {
        this.$alert('请勾选要删除的数据！');
        return;
      }
      this.$confirm('此操作将永久删除该数据, 是否继续?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(async () => {
          let ids = this.selectDataArr.map((sd) => sd.billId);
          try {
            await deleteDecoration(ids);
            this.$message.success('删除成功!');
            this.queryData({ current: 1 });
          } catch (error) {
            this.$message.fail('删除失败!');
          }
        })
        .catch(() => {
          this.$message.info('已取消删除');
        });
    },
    //表格按钮点击事件监听
    handleBtnClick(type, row = {}) {
      switch (type) {
        case 'preview':
        case 'edit':
        case 'approval':
          this.$refs.dialog.show({
            type,
            data: JSON.parse(JSON.stringify(row)),
          });
          break;
        case 'delete':
          this.$confirm('此操作将永久删除该数据, 是否继续?', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
          })
            .then(async () => {
              try {
                await deleteDecoration([row.billId]);
                this.$message.success('删除成功!');
                this.queryData({ current: 1 });
              } catch (error) {
                this.$message.fail('删除失败!');
              }
            })
            .catch(() => {
              this.$message.info('已取消删除');
            });
          break;
        case 'upload':
          break;
        default:
          break;
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.history-div {
  .history-detail {
    position: relative;
    overflow: hidden;
    .update {
      float: right;
    }
  }
}
</style>
<style lang="scss">
.history-div {
  .history-detail {
    .el-button {
      span {
        margin-right: 0 !important;
      }
    }
  }
}
</style>
